package com.msun.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.msun.constant.MessageConstant;
import com.msun.entity.Result;
import com.msun.pojo.*;
import com.msun.service.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/report")
public class ReportController {

    @Reference
    MemberService memberService;
    @Reference
    SetmealService setmealService;
    @Reference
    OrderService orderService;
    @Reference
    FoodService foodService;
    @Reference
    SportsService sportsService;

    @RequestMapping("/findById")
    public Result findById(Integer id){
        Map map=new HashMap();

        try{
            Member member= memberService.findMemberById(id);
            map.put("member",member);

            Setmeal setmeal= setmealService.findSetmealById(id);
            map.put("setmeal",setmeal);

            Order order=   orderService.findOrderById(id);
            map.put("order",order);

            List<String> foods= foodService.findFoodById(id);
            map.put("foods",foods);

            List<String> sports=sportsService.findSportsById(id);
            map.put("sports",sports);

        }catch (Exception e){
            e.printStackTrace();
            return new Result(false, MessageConstant.GET_INFO_FAIL);
        }

        return new Result(true,MessageConstant.GET_INFO_SUCCESS,map);

    }
}
